
/**
 * 
 */
package no.gnet.util;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.GregorianCalendar;

import no.gnet.s10.broker.Broker;
import no.gnet.s10.broker.ConnectionProvider;
import no.gnet.s10.types.Player;

/**
 * @author Gaute
 *
 */
public class TrainingCreator {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Broker.getBroker().setConnprovider(new ConnectionProvider() {
		
			public Connection getConnection() throws SQLException {
				try {
					Class.forName("com.mysql.jdbc.Driver").newInstance();
				} catch(Exception e) {
					System.out.println(e.toString());
				}
				return DriverManager.getConnection("jdbc:mysql://localhost:3306/s10",
						"root", "heiabrann");
			}});
		Calendar cal = GregorianCalendar.getInstance();
		cal.set(2006, 9, 15);		
		for(int i=0;i<(4*52);i++){
			int training_id = Broker.getBroker().createTraining(new Date(cal.getTime().getTime()),1);
			Player [] players = Broker.getBroker().getAllPlayers();
			for (int j = 0; j < players.length; j++) {
				Player player = players[j];
				Broker.getBroker().bookPlayer(training_id, player.getId(), Constants.ACTION_DUNNO);
			}			
			cal.add(Calendar.DATE, 7);
		}
			

	}

}
